package com.fanshuai.soring.boot.webflux;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.web.reactive.DispatcherHandler;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Slf4j
public class MyDispatcherHandler extends DispatcherHandler {
    ApplicationContext context = null;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        super.setApplicationContext(applicationContext);
        this.context = applicationContext;
    }

    @Override
    public Mono<Void> handle(ServerWebExchange exchange) {
        try {
            log.info("begin handle, exchange={}", exchange);
            return super.handle(exchange);
        } finally {
            log.info("handler completed");
        }

    }
}
